function init(){
	getCondition();
	//w调用日期选择插件
	var date = new Date()
	with(date) {
		year = date.getYear() + 1900;
		month = date.getMonth() + 1;
	}
	month = month > 9 ? month : "0" + month;
	var firstDay = year + "-" + month + "-01";
	var today = new Date().format("yyyy-MM-dd");
	$('#datePicker').val(firstDay + " - " + today);
	$('#datePicker').daterangepicker({
		format: 'YYYY-MM-DD',
	    startDate: firstDay,
	    endDate: today
	});
	$(".select-box ul").on('click','li',function(){
	    $(this).parent().siblings('.show').val($(this).html());
	    $(this).parent().siblings('.hidden').val($(this).attr('data-id'));
	    getCondition();
	});
	$(".select-box div.fl").click(function(e){
	    e.stopPropagation();
	    var div=$(this);
	    div.children('ul').toggleClass('hide');
	    $(document).click(function() {
	        if (!div.children('ul').hasClass("hide")) {
	            div.children('ul').addClass("hide");
	        }
	    });
	});
	$('body').on('click','.applyBtn',function(){
		getCondition();
	 });
	var myChart2 = echarts.init(document.getElementById('chart-block'));
    var option = {
        grid:{
            left:'100px',
            top:'100px'
        },
        tooltip: {
            trigger: 'axis',
            formatter: "日期:{b}<br/>数量:{c}",
            padding:[10,15],
            backgroundColor:'#555556',
            axisPointer: {
                type: 'cross'
            }
        },
        color:["#F7D46D"],
        toolbox: {
            feature: {
                dataView: {show: false, readOnly: false},
                magicType: {show: false, type: ['line']},
                restore: {show: false},
                saveAsImage: {show:false}
            }
        },
        xAxis:{
                data: [],
                name: '日期',
                axisLabel:{
                    interval:0
                },
            },
        yAxis: [
            {
                type: 'value',
                name: '数量',
                max:'dataMax',
                min:'dataMin',
//                interval:1,
                axisLabel: {
                    formatter: '{value}'
                }
            }

        ],
        series: [
            {
                name:'订单数量',
                type:'line',
                data:[]
            },
        ]
    };
//	加载订单数/退单数/订单金额/退单金额等数据
	function getCondition(){
		var date = $('#datePicker').val();
	    arr=date.split(" - "); 
	    var startDate = arr[0];
	    var endDate = arr[1];
	    var customerType = $('#customerTypeId').val();
	    var dataType = $('#data_type').val();
	    $.ajax({
	    	type:'POST',
	    	url:path + '/orderlang/order/orderReport',
	    	data:{
	    		startTime:startDate,
	    		endTime:endDate,
	    		customerType:customerType
	    	},
	    	success:function(data){
	    		console.log(data);
	    		if(data.state == 1){
	    			var orderdataList = data.data.orderStatisticsVO;
	    			var rejectdataList = data.data.rejectStatisticsVO;
	    			$(".order_count").html(orderdataList.orderCount + "笔");
	    			$(".return_count").html(rejectdataList.rejectCount + "笔");
	    			$(".order_customer_count").html(orderdataList.orderCustomer + "个");
	    			$(".return_customer_count").html(rejectdataList.rejectCustomer + "个");
	    			$(".order_price").html(cc(orderdataList.orderAmount.toString()));
	    			$(".return_price").html(cc(rejectdataList.rejectAmount.toString()));
	    			if(dataType == "订单数量"){
	    				option.xAxis.data = [];
	    				option.series[0].data = [];
	    				option.yAxis[0].interval = 1;
	    				option.yAxis[0].name = '数量';
	    				option.tooltip.formatter = "日期:{b}<br/>数量:{c}";
	    				if(orderdataList.orderReportList.length == 0){
		    				promtp("暂无数据,请重新选择");
		    			}else{
		    				for(var i = 0;i<orderdataList.orderReportList.length;i++){
		    					option.xAxis.data.push(orderdataList.orderReportList[i].orderTimeShow);
			        			option.series[0].data.push(orderdataList.orderReportList[i].count);
			        		};
		    			}
	    			}else if(dataType == "退单数量"){
	    				option.xAxis.data = [];
	    				option.series[0].data = [];
	    				option.yAxis[0].interval = 1;
	    				option.yAxis[0].name = '数量';
	    				option.tooltip.formatter = "日期:{b}<br/>数量:{c}";
	    				if(rejectdataList.rejectReportList.length == 0){
		    				promtp("暂无数据,请重新选择");
		    			}else{
		    				for(var i = 0;i<rejectdataList.rejectReportList.length;i++){
		    					option.xAxis.data.push(rejectdataList.rejectReportList[i].rejectTimeShow);
			        			option.series[0].data.push(rejectdataList.rejectReportList[i].count);
			        		};
		    			}
	    			}else if(dataType == "订单金额"){
	    				option.xAxis.data = [];
	    				option.series[0].data = [];
	    				option.yAxis[0].name = '金额';
	    				option.tooltip.formatter = "日期:{b}<br/>金额:{c}";
	    				option.yAxis[0].interval = "";
	    				if(orderdataList.orderReportList.length == 0){
		    				promtp("暂无数据,请重新选择");
		    			}else{
		    				for(var i = 0;i<orderdataList.orderReportList.length;i++){
		    					option.xAxis.data.push(orderdataList.orderReportList[i].orderTimeShow);
			        			option.series[0].data.push(orderdataList.orderReportList[i].amount);
			        		};
		    			}
	    			}else if(dataType == "退单金额"){
	    				option.xAxis.data = [];
	    				option.series[0].data = [];
	    				option.yAxis[0].name = '金额';
	    				option.tooltip.formatter = "日期:{b}<br/>金额:{c}";
	    				option.yAxis[0].interval = "";
	    				if(rejectdataList.rejectReportList.length == 0){
		    				promtp("暂无数据,请重新选择");
		    			}else{
		    				for(var i = 0;i<rejectdataList.rejectReportList.length;i++){
		    					option.xAxis.data.push(rejectdataList.rejectReportList[i].rejectTimeShow);
			        			option.series[0].data.push(rejectdataList.rejectReportList[i].amount);
			        		};
		    			}
	    			}
	    			myChart2.setOption(option);
	    		}
	    	},
	    	error:function(){
	    	}
	    })
	};
}
init();
